<?php
// @formatter:off
/**
 * @file s.switchgroup.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-06-16 23:56:49 +0000 (Sun, 16 Jun 2013) $
 *
 * $Id: s.switchgroup.php 73 2013-06-16 23:56:49Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0.0.1/themes/default/controlers/simplecontainer/s.switchgroup.php $
 */
// @formatter:on

if(defined('__SIMPLE_CONTAINER__')) {
	if($wcProfile->allowedTo(WC_PERM_GROUP_SWITCH)) {
		global $wcGroupsHolder;

		$wcThemeAssigns['ACTIONCONTENT'] = "/simplecontainer/s.switchgroup.html";

		$groups = array();
		foreach($wcGroupsHolder->groups() as $group) {
			if($wcProfile->grantedGroup($group) && is_readable($group->root)) {
				$groups[$group->name] = $group;
			}
		}
		ksort($groups);

		$wcThemeAssigns['GROUPS'] = array();
		foreach($groups as $group) {
			$wcThemeAssigns['GROUPS'][] = array(
				"id" => $group->id,
				"name" => $group->name
			);
		}
	} else {
		$wcThemeAssigns["error-string"] = "You're not allowed to jump to another group.";
		require "{$this->_themeRoot}/controlers/contents/c.403.php";
	}
}
?>